package com.lorenzogao.pley

import android.app.Application
import android.content.Context
import android.view.View
import com.lorenzogao.pley.ui.di.component.AppComponent
import com.lorenzogao.pley.ui.di.component.DaggerAppComponent
import com.lorenzogao.pley.ui.di.moduel.AppModule
import com.lorenzogao.pley.ui.di.moduel.HttpModule

/**
 * 作者：Lorenzo Gao
 * Date: 2017/12/27
 * Time: 13:21
 * 邮箱：2508719070@qq.com
 * Description:
 */
class AppApplication : Application() {

    private lateinit var mAppComponent: AppComponent


    lateinit var mView: View

    companion object {
        fun get(context: Context): AppApplication {
            return context.applicationContext as AppApplication
        }
    }

    override fun onCreate() {
        super.onCreate()

        mAppComponent = DaggerAppComponent.builder()
                .appModule(AppModule(this))
                .httpModule(HttpModule())
                .build()

    }


    fun setView(view: View) {
        this.mView = view
    }

    fun getView(): View {

        return mView
    }

    fun getAppComponent(): AppComponent {

        return mAppComponent
    }

}